//login.js
//获取应用实例
var app = getApp();
Page({
  data: {
    remind: '加载中',
    angle: 0,
    userInfo: {}
  },

  onLoad: function (options) {
    var that = this
    wx.getSetting({
      success: function (res) {
        if (res.authSetting['scope.userInfo']) {
          wx.switchTab({
            url: '/pages/index/index',
          })
        } else {
          if (options.userid) {
            console.log(options.userid)
            app.user.user = options.userid
            console.log(app.user.user)
          }
        }
      },
    })

  },
  getuserInfo1: function (e) {
    let that = this
      wx.getUserInfo({
        success: res => {
          app.getOpenid()
          app.globalData.userInfo = e.detail.userInfo
          wx.switchTab({
            url: '/pages/index/index',
          });
        }
      })
  },
  onReady: function () {
    var that = this;
    setTimeout(function () {
      that.setData({
        remind: ''
      });
    }, 1000);
    wx.onAccelerometerChange(function (res) {
      var angle = -(res.x * 30).toFixed(1);
      if (angle > 14) {
        angle = 14;
      } else if (angle < -14) {
        angle = -14;
      }
      if (that.data.angle !== angle) {
        that.setData({
          angle: angle
        });
      }
    });
  }
});